﻿<MTextField Value="Value"
            ValueChanged="ValueChanged"
            Class="@Class"
            Dense="@Dense"
            Flat
            Clearable="@Clearable"
            Placeholder="@Placeholder" 
            HideDetails="true"
            OnKeyDown="HandleOnKeyDown"
            Solo
            BackgroundColor="@BackgroundColor"
            Style="@($"border-radius:10px; mix-blend-mode: normal;{Style}")"
            OnClearClick="OnClearClick">
            <PrependInnerContent>
                <SIcon Size=16 Class="mr-2 neutral-text-emphasis-secondary" Style="padding-top:2px" IsDefaultToolTip="false">mdi-magnify</SIcon>
            </PrependInnerContent>
</MTextField>

@code {

    [Parameter]
    public string? Value { get; set; }

    [Parameter]
    public EventCallback<string?> ValueChanged { get; set; }

    [Parameter]
    public string? Class { get; set; }

    [Parameter]
    public bool Dense { get; set; }

    [Parameter]
    public EventCallback OnEnter { get; set; }

    [Parameter]
    public string? Style { get; set; }

    [Parameter]
    public string Placeholder { get; set; } = "";

    [Parameter]
    public string BackgroundColor { get; set; } = default!;

    [Parameter]
    public bool Clearable { get; set; }

    [Parameter]
    public EventCallback<MouseEventArgs> OnClearClick { get; set; }

    private async Task HandleOnKeyDown(KeyboardEventArgs args)
    {
        if (args.Key == "Enter" && OnEnter.HasDelegate)
        {
            await OnEnter.InvokeAsync();
        }
    }

}